package com.example.w.common.util;

import java.util.Random;

public class SaltUtils {
    private static char c[];
    static {
        c =
        "ABCDEFGHIJKLLMOPQRSTUVWXYZabcdefghijkllmopqrstuvwxyz1234567890!@#$%^&*()".toCharArray();
    }

    /**
     * 获取指定位数的盐
     * @param n 指定盐的位数
     * @return 需要的盐
     */
    public static String getSalt(int n) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < n; i++) {
            builder.append(c[new Random().nextInt(c.length)]);
        }
        return builder.toString();
    }

    /*public static void main(String[] args) {
        System.out.println(getSalt(8));
    }*/
}
